<template>
	<view class="template">
		<view class="content">
			<view class="QRbox" @click="QRFn">
				<u-icon name="scan" color="#00aaff" size="100"></u-icon>
			</view>
			<view class="sumBox">
				<u--input placeholder="请输入数量" border="surround" v-model="num" type="number" clearable></u--input>
			</view>
			<!-- <u-button text="提交" :disabled="submitDis" @click="submit"></u-button> -->
			<view class="sub">
				<text>库位：</text>
				<text>{{ successData }}</text>
			</view>
		</view>
	</view>
</template>

<script setup>
export default {
	data() {
		return {
			num: '',
			// QRcond: null,
			successData: ''
		};
	},
	computed: {
		// submitDis: {
		// 	get() {
		// 		return !this.num || !this.QRcond;
		// 	}
		// }
	},
	methods: {
		QRFn() {
			if (!this.num || this.num == 0) {
				uni.showToast({
					icon: 'none',
					title: '请先输入数量'
				});
				return;
			}
			uni.scanCode({
				success: (res) => {
					console.log('条码类型：' + res.scanType);
					console.log('条码内容：' + res.result);
					uni.showToast({
						icon: 'success',
						title: '扫描成功'
					});
					this.QRcond = res.result;
					const url = 'api/Send/sendget?bq=' + res.result + '&sl=' + this.num;
					// console.log('url', url);
					this.http.get(url, {}).then((result) => {
						console.log('扫码请求', result);
						this.successData = result;
						uni.showToast({
							icon: 'none',
							duration: 2000,
							title: result
						});
					});
				}
			});
		}
		// submit() {
		// 	if (this.QRcond == null) {
		// 		uni.showToast({
		// 			icon: 'none',
		// 			title: '请先扫描二维码'
		// 		});
		// 		return;
		// 	}
		// 	if (!this.num) {
		// 		uni.showToast({
		// 			icon: 'none',
		// 			title: '请输入数量'
		// 		});
		// 		return;
		// 	}
		// 	const url = 'api/Send/sendget?bq=' + this.QRcond + '&sl=' + this.num;
		// 	console.log('url', url);
		// 	this.http.get(url, {}).then((result) => {
		// 		console.log('扫码请求', result);
		// 		this.successData = result
		// 		uni.showToast({
		// 			icon: 'none',
		// 			duration: 2000,
		// 			title: result
		// 		});
		// 	});
		// }
	}
};
</script>

<style lang="scss" scoped>
.template {
	display: flex;
	justify-content: center;
	align-items: center;
	height: 100vh;
	background-color: #f8f8f8;
}
.content {
	width: 80%;
	// background-color: #f8f8f8;
	padding-bottom: 20vh;
	.QRbox {
		margin-bottom: 20rpx;
	}
	.sumBox {
		border: 1px solid #c5c5c5;
		border-radius: 10rpx 10rpx;
		overflow: hidden;
		margin-bottom: 20rpx;
	}
	.u-icon {
		display: flex;
		justify-content: center;
		align-items: center;
	}
}
</style>
